<?
get_header();
?>

<td>
	<div id="content">
		<?
		query_posts('post_type=produto&cat=' . $cat);
		$refers = array();
		while (have_posts()) {
			the_post();
			
			$refer = get_post_meta($post->ID, 'meta_box_referencia', true);
			if(in_array($refer, $refers)) {
				continue;
			}
			$refers[] = $refer;
			
			if (has_post_thumbnail($post_id)) {
				$default = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
				$img = $default[0];
			} else {

				$args = array(
					'order' => 'ASC',
					'orderby' => 'menu_order',
					'post_type' => 'attachment',
					'numberposts' => -1,
					'post_status' => null,
					'post_parent' => $post->ID
				);

				$attachments = get_posts($args);
				if ($attachments) {
					foreach ($attachments as $attachment) {
						$default = wp_get_attachment_image_src($attachment->ID, 'large');
						break;
					}
					$img = $default[0];
				}
			}
			?>

			<div class="produto left">
				<div class="area_produto">
					<div class='imagem'><a href='<?= get_permalink(); ?>' alt="<?= strtolower(get_the_title()); ?>" title="<?= strtolower(get_the_title()); ?>"><img src='<?= get_bloginfo("template_url"); ?>/img.php?src=<?= $img; ?>&w=180&h=150&zc=1' border='0'></a></div>
					<div class='titulo'><a href='<?= get_permalink(); ?>' alt="<?= strtolower(get_the_title()); ?>" title="<?= strtolower(get_the_title()); ?>"><?= get_the_title(); ?></a></div>
					<div class='preco'>R$ <?= get_post_meta($post->ID, 'meta_box_preco', true); ?></div>
					<div class="scProduto"><a href="<?= get_permalink(); ?>"><img src="<?= get_bloginfo('template_url') . '/img/button-comprar.png' ?>" border="0"></a></div>
							<?
							if (get_post_meta($post->ID, 'meta_box_frete', true) == 'on') {
								echo "<div class='gratis'>frete gr&aacute;tis</div>";
							}
							?>
				</div>
			</div>
			<?
		}
		?>


	</div> <!--  #content -->
</td>
<? get_footer(); ?>
